How to store data result
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
lucky_
am 21 Jan. 2016
Kommentiert: Star Strider
am 22 Jan. 2016
I want to store this line in variable x so then I can plot it is that possible
x= [dataset1, dataset2] = myfunction(sample1); %I know this doesn't work , but I just wanted to give clear example
figure
plot(x(:,1) , x(:,2) , 'b.');
2 Kommentare
Image Analyst
am 21 Jan. 2016
What kind of arrays, and how many, do you want your function to return?
Akzeptierte Antwort
Star Strider
am 21 Jan. 2016
Bearbeitet: Star Strider
am 21 Jan. 2016
That depends on how you write your function. If you write it as something like this:
function x = myfunction(sample1)
. . . CALCULATIONS . . .
dataset1 = . . .;
dataset2 = . . .;
x = [dataset1, dataset2];
end
Then ‘x’ would be an (Nx2) matrix that you could then plot as:
figure(1)
plot(x(:,1) , x(:,2) , 'b.')
NOTE — I did not actually test this, but it should work.
3 Kommentare
Star Strider
am 21 Jan. 2016
I apparently misunderstood. If you want ‘x’ to be as you defined it, you need to break it up into two separate statements:
[dataset1, dataset2] = myfunction(sample1);
x = [dataset1, dataset2];
then this will work:
figure(1)
plot(x(:,1) , x(:,2) , 'b.');
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Annotations finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!