MATLAB Answers

0

Problem with my code?

Asked by GEORGIOS BEKAS on 18 Oct 2019 at 20:20
Latest activity Commented on by madhan ravi
on 18 Oct 2019 at 20:39
I wrote the following code that is based on reading two csv files that I include.
clc
clear
a = dlmread ('gb.csv')
b = dlmread ('gb2.csv')
function [Qfresh,Qsea] = concentration(CCLspring,Qspring)
CCLsea=19000;
CCLfresh=10;
%Qfresh = Qspring*(CCLsea-CCLspring)/(CCLsea-CCLfresh)
Qsea = Qspring*(CCLspring-CCLfresh)/(CCLsea-CCLfresh)
end
size(a)
size(b)
M=zeros(size(a,1),size(a,2));
for i = 1:size(a,1)
for j = 1:size(a,2)
M(i,j) =concentration(a(i,j),b(i,j))
end
end
I get the following message that I don't understand: 'error: value on right hand side of assignment is undefined'.

  0 Comments

Sign in to comment.

2 Answers

Star Strider
Answer by Star Strider
on 18 Oct 2019 at 20:31

I do not see that you defined ‘Qfresh’ anywhere in your function.

  0 Comments

Sign in to comment.


Answer by Kevin Phung on 18 Oct 2019 at 20:33

looks like you included a space:
%a = dlmread ('gb.csv')
%b = dlmread ('gb2.csv')
a = dlmread('gb.csv')
b = dlmread('gb2.csv')
also it seems like dlmread is not recommended: https://www.mathworks.com/help/matlab/ref/dlmread.html

  1 Comment

madhan ravi
on 18 Oct 2019 at 20:39
The space doesn’t cause the error as the OP describes.

Sign in to comment.