Info

La pregunta está cerrada. Vuélvala a abrir para editarla o responderla.

error when reading from xls sheet

1 visualización (últimos 30 días)
Ayda
Ayda el 31 de Oct. de 2011
Cerrada: MATLAB Answer Bot el 20 de Ag. de 2021
Good evening\morning
I have a system of equations and i expressed them in matrix form
R=[ R(3)+R(5)+R(8) , -R(5) , 0 , -R(3);
-R(5), R(1)+R(4)+R(5)+R(7) , -R(4), 0;
0, -R(4) , R(2)+R(4)+R(6) , -R(6);
-R(3) , 0 , -R(6) , R(3)+R(6)+R(9)];
V= [V(1);0;0;V(2)];
I've to do a matrix division and some other things But when I read the voltages values from xls file as
10
0
0
10
it read it Matrix V (in Volts)
10.0
0.0
0.0
0.0
Also when it try to enter the value from the terminal it read it as zero
fid= fopen('mesh.txt','w');
% R=input('inter resistor value in kilo ohms, [R1...R9]= ');
R=xlsread('test');
% V=input('inter voltage value in volt, [V1 V2]= ');
V=xlsread('v');
R=[ R(3)+R(5)+R(8) , -R(5) , 0 , -R(3);
-R(5), R(1)+R(4)+R(5)+R(7) , -R(4), 0;
0, -R(4) , R(2)+R(4)+R(6) , -R(6);
-R(3) , 0 , -R(6) , R(3)+R(6)+R(9)];
V= [V(1);0;0;V(2)];
fprintf(fid,'Matrix R (in Kohms)\n\n');
fprintf(fid,'\t%.1f\t\t %.1f\t\t %.1f\t\t %.1f\t\n\n',R);
fprintf(fid,'Matrix V (in Volts)\n\n');
fprintf(fid,'%.1f\n %.1f\n %.1f\n %.1f\n\n',V);
I=R\V;
fprintf(fid,'Mesh Currents I (in mAmber)\n\n');
fprintf(fid,'%.4f\n %.4f\n %.4f\n %.4f\n\n',I);
inverse= inv(R);
fprintf(fid,'Inverse of R (in Kohms)\n\n');
fprintf(fid,'%.4f\t %.4f\t %.4f\t %.4f\t\n\n',inverse);
I=invers\V;
fprintf(fid,'Mesh Currents I (in mAmber)\n\n');
fprintf(fid,'%.4f\n %.4f\n %.4f\n %.4f\n',I);
fclose(fid);
  1 comentario
bym
bym el 31 de Oct. de 2011
I think you have a number of typographical errors (typos) in your code; plus formatting it using the {}Code button would help readability and increase the probability someone would provide the answer you seek

Respuestas (1)

Ken Atwell
Ken Atwell el 2 de Nov. de 2011
If the file 'v' contains '10;0;0;10', the statement:
V= [V(1);0;0;V(2)];
two lines later would reset V to '10;0;0;0' as you are observing. Do you mean:
V = [V(1); V(4)];

La pregunta está cerrada.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by