plotting - field from a structure

4 views (last 30 days)
Pankaj
Pankaj on 27 Jan 2012
I have the following code in which I fill a structure and then try to plot one of the fields of the structure.
returnProfile = struct('totalReturn',{});
j =0;
for i = 16:8:104
j = j+1;
returnProfile(j,1) = maLong(i/2,i,i/8,i/4);
y(j,1) = i;
end
plot(returnProfile(:).totalReturn,y(:,1));
#*The plot doesn't show anything. am not sure why?* y is an array should "returnProfile(:).totalReturn" be an array i dont see any reason why the plot should not work. all elements are generated as:
y(:,1)
ans =
16
24
32
40
48
56
64
72
80
88
96
104
>> returnProfile(:).totalReturn
ans =
1.6862
ans =
-8.8583
ans =
3.3551
ans =
-4.0201
ans =
-5.0018
ans =
-25.9340
ans =
15.1983
ans =
-10.6162
ans =
15.5172
ans =
4.4779
ans =
-11.4196
ans =
-23.1088

Accepted Answer

Walter Roberson
Walter Roberson on 27 Jan 2012
plot([returnProfile.totalReturn],y(:,1));

More Answers (0)

Categories

Find more on Line Plots in Help Center and File Exchange

Products

Community Treasure Hunt

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

Start Hunting!