oliver
oliver

Reputation: 147

How to plot the scatter plot of the following simulation in Matlab?

I have the following code to get result

result=zeros(1,100)
i=0
for x=0:0.5:50
    i=i+1
    mat=[-12,4,4;4,6,-x-10;-8,-1,-x]
    con=[-120;0;-240]
    X = linsolve( mat,con)
    result(1,i)=X(3,1)
end

I try to plot the x=0:0.5:19 and its corresponding result y=result(1:39)

xlabel('resistance'), ylabel(' through the fuse')     % Set the label on the corresponding axis

y=result(1:39)
x=0:0.5:19
plot(x, y)             % plot the values of x and y as a line plot
scatter(x, y)          % plot the values of x and y in a scatter plot
xline(x), yline(y)     % draw a vertical / horizontal line at the specified value

But it shows the error...

Upvotes: 0

Views: 34

Answers (1)

Ahmed AEK
Ahmed AEK

Reputation: 17386

in this line:

y=result(1:39)

you have a forgeign letter this is not the ASCII character :, it's a Unicode character U+FF1A that is causing an issue, simply replace it and things will work.

y=result(1:39)

Upvotes: 1

Related Questions