How to display table of values on Matlab?

조회 수: 2 (최근 30일)
Thamer
Thamer 2013년 8월 14일
So I figured I want my resistance values to be displayed on a table once I run my code. However, instead of giving me a value for the resistors, it is giving me "1x1 sym" as an answer on the table. I want it to display the actual calculated vale for R1, R2, R3, R4, Vde, and R_ab.
Here's my code:
clear all;
clearvars;
close all;
clc;
Vs=10.0; %Supply voltage in Volts
prompt={'Enter value for R_bd: ', 'Enter value for R_ad: ', 'Enter value for R_ae: ', 'Enter value for R_be: ', 'Enter Value for Vad: ', 'Enter Value for Vdb: '};
answer=inputdlg(prompt, 's');
R_bd = str2double(answer(1));
R_ad = str2double(answer(2));
R_ae = str2double(answer(3));
R_be = str2double(answer(4));
Vad = str2double(answer(5));
Vdb = str2double(answer(6));
syms R1 R2 R3 R4 positive;;
equ1=R_bd-R1*(R2+R3+R4)/(R1+R2+R3+R4);
equ2=R_ad-R2*(R1+R3+R4)/(R1+R2+R3+R4);
equ3=R_ae-R3*(R1+R2+R4)/(R1+R2+R3+R4);
equ4=R_be-R4*(R1+R2+R3)/(R1+R2+R3+R4);
sol=solve(equ1,equ2,equ3,equ4);
R1=sol.R1
R2=sol.R2
R3=sol.R3
R4=sol.R4
%Vde is the voltage of node D relative to node E in mV
Vde=(R1/(R1+R2)-R4/(R3+R4))*Vs*1000
R_ab=((R1+R2)*(R3+R4))/(R1+R2+R3+R4)
I1a=Vad/R2;
R1a=Vdb/I1a
tableData{1,1} = 'R1';
tableData{2,1} = 'R2';
tableData{3,1} = 'R3';
tableData{4,1} = 'R4';
tableData{5,1} = 'Vde';
tableData{6,1} = 'R_ab';
tableData{1,2} = R1;
tableData{2,2} = R2;
tableData{3,2} = R3;
tableData{4,2} = R4;
tableData{5,2} = Vde;
tableData{6,2} = R_ab;
tableData{1,3} = ('Ohms');
tableData{2,3} = ('Ohms');
tableData{3,3} = ('Ohms');
tableData{4,3} = ('Ohms');
tableData{5,3} = ('mV');
tableData{6,3} = ('Ohms');
If you run it, input any values you want that it asks you it doesn't matter. You will see that if you check the table it generated under tableData 6x3 cell in Workspace, the second column only shows 1x1 sym for the values instead of the calculated number I want it to show.
Is there a way to fix that? If there is another way to tabulate my results that's fine. I just want it tobe in a table format so it is easier to read.
Thank you

채택된 답변

Azzi Abdelmalek
Azzi Abdelmalek 2013년 8월 14일
tableData{1,2} = double(R1);
tableData{2,2} = double(R2);
tableData{3,2} = double(R3);
tableData{4,2} = double(R4);
tableData{5,2} = double(Vde);
tableData{6,2} = double(R_ab);

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Data Import and Network Parameters에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by