Run Two Scripts over Single Chart

4 visualizaciones (últimos 30 días)
Dima
Dima el 16 de En. de 2012
Hello!) I was wondering if there is an easy way to run two similar scripts one after another so that their output is placed on the same chart. lets say I have 222.m scrip and 333.m scrip...I tried this code in teh scrip called TWO
figure(1);hold on;
222.m
333.m
and it gives off the followign error:
??? Attempt to reference field of non-structure array.
Error in ==> TWO at 2
222.m
Thanks!

Respuesta aceptada

Dima
Dima el 16 de En. de 2012
thanks for the reply...here is a more expanded example of combining scripts. I have two scripts named chart1.m and chart2.m as follows:
%chart1
x = 0:.2:20;
y = sin(x)./sqrt(x+1);
y(2,:) = sin(x/2)./sqrt(x+1);
y(3,:) = sin(x/3)./sqrt(x+1);
plot(x,y)
and chart2:
%chart2
x = -pi:.1:pi;
y = sin(x);
plot(x,y)
I try to run these two codes one after another and have their output recorded on one chart:
%combined charts
figure(1);hold on;
chart1.m
chart2.m
and still I get the followign error:
Warning: Direct access of structure fields returned by a function call (e.g.,
call to chart1) is not allowed. See MATLAB 7.10 Release Notes, "Subscripting Into Function Return Values" for details.
> In combinedcharts at 2
??? Attempt to reference field of non-structure array.
Error in ==> combinedcharts at 2
chart1.m
I wonder what do you think is causing this error?
Thanks!
  2 comentarios
Chandra Kurniawan
Chandra Kurniawan el 16 de En. de 2012
I wrote
figure(1);hold on;
chart1
chart2
And it works just fine on my machine
Dima
Dima el 16 de En. de 2012
works for this scrip combination...but what about if I have two larger scripts each of which create their own figure(1)..I mean how do I continue plotting on the figure (1) that was created by the first scrip after that script is finished and the next is started? because with the larger scripts it looks like the figure is recreated when the second script is started...
thanks a lot!)))

Iniciar sesión para comentar.

Más respuestas (2)

Ilham Hardy
Ilham Hardy el 16 de En. de 2012
Have you compile and debug the 222.m? It seems the problem lies on the shadowing parameter. Based on the error message you need to check the parameter 'TWO' on 222.m script (lines #2).
Check as well your workspace wheteher the parameter 'TWO' is still correct or accidentally overwritten.

Ilham Hardy
Ilham Hardy el 16 de En. de 2012
For calling a function (which reside on current path) you just need to use the filename, without file extension.
Try alter your combined chart fun to: %combined charts figure(1);hold on; chart1 chart2
HTH;IH

Categorías

Más información sobre Multidimensional Arrays en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by